﻿using System;
using System.Collections.Generic;
using System.Text;
using YouHP.Model;
using YouHP.DALFactory;
using System.Data;

namespace YouHP.BLL
{
    public class MessageBLL
    {
        #region 单件模式
        static MessageBLL _Instance;

        public static MessageBLL Instance
        {
            get
            {
                if (_Instance == null)
                {
                    _Instance = new MessageBLL();
                }
                return _Instance;
            }
        }
        #endregion

        #region 添加删除修改

        public MessageInfo GetMessage(int Pmid)
        {
            return DataAccess.MessageDAL.GetMessage(Pmid);
        }

        public bool DeleteMessage(int[] pmitemid)
        {
            return DataAccess.MessageDAL.DeleteMessage(pmitemid);
        }

        public List<MessageInfo> GetMessageListByUserId(int pageSize,int pageIndex,int uid,bool isTo, out int count)
        {
            return DataAccess.MessageDAL.GetMessageListByUserId(pageSize, pageIndex, uid,isTo, out count);
        }

        public bool  CreateMessage(MessageInfo Pm)
        {
            return DataAccess.MessageDAL.CreateMessage(Pm);
        }

        #endregion
        
        //更新短消息读状态
        public bool UpdatePmState(int uid, int IsRead)
        {
            return DataAccess.MessageDAL.UpdatePmState(uid, IsRead);
        }

        public List<MessageInfo> GetMsgReplyList(int pageSize, int pageIndex, int msgid, out int count)
        {
            return DataAccess.MessageDAL.GetMsgReplyList(pageSize,pageIndex,msgid,out count);
        }

        //得到新短消息的条数
        public int GetNewMessageCount(int uid)
        {
            return DataAccess.MessageDAL.GetNewMessageCount(uid);
        }
    }
}
